import axios from 'axios';
const  request =axios.create({
    baseURL:'http://127.0.0.1:3000',
    timeout:5000,
    headers:{
        'Content-Type':'application/json'
    },
})
// 请求拦截器
request.interceptors.request.use(
    config => {
      // 在发送请求之前做些什么
      // config.headers.Authorization = 'Bearer ' + localStorage.getItem('token')
      return config
    },
    error => {
      // 对请求错误做些什么
      return Promise.reject(error)
  })
  // 响应拦截器
  request.interceptors.response.use(
    response => {
      return response.data
    }
    , error => {
      // 对响应错误做点什么
      return Promise.reject
    }
  )
 const get=(url,params)=>{
    return request.get(url,{params})
 }
 const post=(url,data)=>{
  console.log(data,'465132');
  
    return request.post(url,data)
 }
 const put=(url,data)=>{
    return request.put(url,data)
 }
 const del=(url,params)=>{
    return request.delete(url,{params})
 }
export  {get,post,put,del}

